﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using YFIN.View.PropertyServiceRef;
using YFIN.View.ViewModels;

namespace YFIN.View.Toolkit
{
    public partial class Property : UserControl
    {
        private PropertyVM _pvm;
        public Property()
        {
            InitializeComponent();
            _pvm = new PropertyVM();
            DataContext = _pvm;
        }

        private void edit_Click(object sender, RoutedEventArgs e)
        {
            _pvm.UpdateContent(((Button)sender).DataContext);
        }

        private void delete_Click(object sender, RoutedEventArgs e)
        {
            _pvm.CurrentPropertyContent = ((Button)sender).DataContext as ModelPropertyContent;
            _pvm.DeleteContent();
        }

        private void AddContentButton_Click(object sender, RoutedEventArgs e)
        {
            _pvm.AddContent(((Button)sender).DataContext as ModelPropertyContent);
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _pvm.CurrentPropertyType = _pvm.PropertyTypes[((ListBox) sender).SelectedIndex];
        }

        private void chart_Click(object sender, RoutedEventArgs e)
        {
            PropertyChart propertyChart = new PropertyChart(_pvm.PropertyTypes);
            propertyChart.Show();
        }
    }
}
